package Dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import Vo.Doctor;

public class LoginDao extends BaseDao {
	public Doctor findadmin(String name,String password){
		Connection con=this.getconnection();
		
		PreparedStatement ps= null;
		
		ResultSet rs=null;
		
		Doctor a=null;
		try {
			String sql="select Dname,Password from Doctor a where a.Dname=? and a.Password=?";
			ps=con.prepareStatement(sql);
			ps.setString(1, name);
			ps.setString(2, password);
			rs=ps.executeQuery();
			if(rs.next()){
				System.out.println(rs.getString("Dname")+rs.getString("Password"));
			
			
				a=new Doctor();
				a.setName(rs.getString("Dname"));
				a.setPassword(rs.getString("password"));
			
			}
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			this.close(con, ps, rs);
		}
		return a;
	}
}
